import cv2 as cv
import numpy as np
import argparse

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="The Path to image")
args = vars(ap.parse_args())

image = cv.imread(args["image"])
B, G, R = cv.split(image)

print("R[94,180] = {}".format(R[94, 180]))
print("B[78,13] = {}".format(B[78, 13]))
print("G[5,80] = {}".format(G[5, 80]))

M1 = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]])
M2 = np.array([[202, 119, 154], [106, 119, 11], [186, 48, 250]])

res = np.dot(M1, M2)
print("Dot Res: {}".format(res))

res = cv.multiply(M1, M2)
print("Multiply(CV) Res :{}".format(res))

# 直接相乘的结果
res = M1 * M2
print("M1 * M2 = {}".format(res))

# 使用哪个np.multiply
res = np.multiply(M1, M2)
print("Multiply(np) Res = {}".format(res))

# 然后再求和
res = np.sum(res)
print("Sum = {}".format(res))

M1 = np.ones((3, 3), dtype=np.uint8) * 1/ 9
M2 = np.array([
    [18, 143, 222],
    [233, 179, 97],
    [234, 142, 149]
])
res = np.sum(M1 * M2)
print("res2 = {}".format(res))
